<style>
	.tableoos thead th{line-height:32px;border:1px solid #EDEDED; font-weight:bolder;}
	.tableoos tbody td{border:1px solid #EDEDED; line-height:24px;}
</style>
<script>
function lev(t,s) {
	var t = t;
	if ( s==1 )t.value = t.value.replace(/\D/g, ''); 
	if ( s==2 ) { t.value = t.value.replace(/[^0-9.]/g, ''); }
	if (t.value.length < 1 || t.value < 1) { t.value = 1 } else if (t.value > 9999) { t.value = parseInt(t.value.substring(0, 4)) };
} 

</script>

<div class="pageContent">
	 <form id="myform" action="{:U('Order/do_ogoods')}" method="post" onsubmit="return validateCallback(this,dialogAjaxDone);">
	 	<input type='hidden' name='oid' value='{$oid}' />
		<input type='hidden' name='ogoodskey' value='{$ogoodskey}' />
   <div class="pageFormContent" layoutH="57">
      
            <fieldset>
                <legend>订单商品信息</legend>
                <div>
                    <table class="tableoos" width="100%" align="center">
                        <thead>
                        <tr align="center">
                            <th width="15%">订单编号</th>
                            <th>商品名称</th>
                            <th width="24%">有效数量</th>
                            <th width="24%">选择产品</th>
                        </tr>
                        </thead>
                        <tbody>
                        	
<if condition="empty($goods)">
                        <tr align="center">
                            <td colspan="4" style="padding:10px;border:0;color:#FB0000;" align="center">订单内没有商品!</td>
                        </tr>
	<else/>
	<volist name="goods" id="vo">
	<php>
		$oosnum=$vo['number'];
		if($goods_finance[$vo['product_id']]){
			foreach($goods_finance[$vo['product_id']] as $o){
				if($o['action']=='OOS' && $o['platform']=='SMW01'){
					$oosnum-=$o['number'];
				}
			}
		}
	</php>
                        <tr align="center">
                            <td rowspan="2" height="60" style="border-left:none;"><a href="#" target="_blank">{$vo['product_psn']}</a></td>
                            <td rowspan="2">
                        
								
								{$vo['product_name']}<br>
								{$vo['price']/100|number_format=###,2} x {$vo['number']}
							</td>
							<td rowspan="2" id="oosnumnow_{$vo['id']}">
								<input type='hidden' id='oldpronum{$vo.product_id}' value='{$oosnum}' />
								{$oosnum}
							</td>
							<td>
{if $oosnum<1}
--<input type='hidden' name='proid[]' value='{$vo.product_id}' />
								<input type='hidden' name='proprice[]' value='{$vo.price}' />
								<input type='hidden' name='proname[]' value='{$vo.product_name}' />
								<input type='hidden' name='proimg[]' value='{$vo.product_thumb}' />
								<input type='hidden' name='procode[]' value='{$vo.product_psn}' />
								<input type='hidden' name='promname[]' value='{$vo.mname}' />
								<input type='hidden' name='pronum[]' value='{$vo['number']}' />
								<input type='hidden' id="oldproprice{$vo.product_id}"  name='' value="{$vo['price']/100}" />
								<input id='proid{$vo.product_id}' name="product{$vo.product_id}.id" value="" type="hidden"/>
								<input id='proname{$vo.product_id}' name="product{$vo.product_id}.name" value="" type="hidden"/>
{else}
								<table width="100%">
								<tr>
								<td>
								<input type='hidden' name='proid[]' value='{$vo.product_id}' />
								<input type='hidden' name='proprice[]' value='{$vo.price}' />
								<input type='hidden' name='proname[]' value='{$vo.product_name}' />
								<input type='hidden' name='proimg[]' value='{$vo.product_thumb}' />
								<input type='hidden' name='procode[]' value='{$vo.product_psn}' />
								<input type='hidden' name='promname[]' value='{$vo.mname}' />
								<input type='hidden' name='pronum[]' value='{$vo['number']}' />
								
								<input type='hidden' id="oldproprice{$vo.product_id}"  name='' value="{$vo['price']/100}" />
									
								</td>
								<td>
									
										<input   id='proid{$vo.product_id}' name="product{$vo.product_id}.id" value="" type="hidden"/>
										<input  class='proname' oldpid='{$vo.product_id}'  style='width:350px;' id='proname{$vo.product_id}' name="product{$vo.product_id}.name" value="" type="text" postField="keywords" suggestFields="id,name,price" suggestUrl="{:U('Content/suggest',array('tn'=>'product','fn'=>'id,name','field'=>'id,name,price,image,code,mname','where'=>myencode(array('status'=>1),1)))}" lookupGroup="product{$vo.product_id}"/>                 
									</td>
								<td>
									
								</td></tr>
								</table>
								
{/if}
							</td>
                        </tr>
						
						<tr>
							<td>
							{if $oosnum>=1}
								价格：<input class='proname'  style='width:50px;' id='newproprice{$vo.product_id}' readonly='readonly' name="product{$vo.product_id}.price"   /> &nbsp; 
								数量：<input class='checkprice required' oldpid='{$vo.product_id}' style='width:50px;' id='newpronum{$vo.product_id}' name="newpronum[]"  value="0"  />
							{else}
								<input type='hidden' name='product{$vo.product_id}.price' id='newproprice{$vo.product_id}'/>
								<input type='hidden' name='newpronum[]' value="0" id='newpronum{$vo.product_id}' />
							{/if}
							</td>
						</tr>
	</volist>
</if>
                        </tbody>
                        </table>
                    </div>
                    </fieldset>
					
					
{if $finance}
                    <fieldset>
                        <legend>订单缺货登记</legend>
<volist name="finance" id="f">
                        <dl class="nowrap">
                            <dt>{if $f['action']=='OOS'}缺货{else}退款{/if}</dt>
                            <dd>{$f['remark']}    {$f['value']/100|number_format=###,2} {$f['subject']}  x {$f['number']}         【{if $f['status']==1}已操作退款{else}未操作退款{/if}】</dd>
                        </dl>
</volist>
                    </fieldset>
{/if}

</div>
          
		<div class="formBar">
            <ul>
                <li>
                    <div class="buttonActive">
                        <div class="buttonContent">
                            <button type="submit">
                                保存
                            </button>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="button">
                        <div class="buttonContent">
                            <button type="button" class="close">
                                取消
                            </button>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
		
				</form>
 </div>
			

			
<script>
$(function(){
	
	$(".checkprice").blur(function(){
		var id = $(this).attr('oldpid');
		var newprice = $("#newproprice"+id).val();
		var newnum = $("#newpronum"+id).val();
		var oldprice = $("#oldproprice"+id).val();
		var oldnum = $("#oldpronum"+id).val();
		
		if(newprice*newnum > oldprice*oldnum){		
			$("#newpronum"+id).val('');
			alert('更换产品总价格【CV:'+newprice*newnum+'】不能大于原来产品的总价格【CV:'+oldprice*oldnum+'】！（总价格 = 单价 * 数量）');
			$("#newpronum"+id).focus();
			$("#newpronum"+id).select();
			return false;		
		}		
		
		
		
	});
	
	$(".proname").blur(function(){
		var id = $(this).attr('oldpid');
		$("#newpronum"+id).focus();
		$("#newpronum"+id).select();
	});
	
});

function checkprice(data){
	
}
</script>
